import { DynamicModule, Module } from '@nestjs/common';
import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm';
import { DataExist } from './core/dto/data-exists';
import { UniqueValidate } from './core/dto/uniqueValidate';
import { UniqueExistValidate } from './core/dto/uniqueExistValidate';
import { UniqueValidateTree } from './core/dto/uniqueValidateTree';
import database from '@/config/database';

@Module({})
export default class DatabaseModule {
  static forRoot(): DynamicModule {
    return {
      global: true,
      module: DatabaseModule,
      imports: [TypeOrmModule.forRoot(database as TypeOrmModuleOptions)],
      providers: [
        DataExist,
        UniqueValidate,
        UniqueExistValidate,
        UniqueValidateTree,
      ],
    };
  }
}
